Skip to content

MINOR FOUNDATION: Repository ForeignKey Tests#332

Merged
glhays merged 4 commits into
mainfrom
users/glhays/minorfoundation-repository-fkTest
Jun 14, 2025
Merged

MINOR FOUNDATION: Repository ForeignKey Tests#332
glhays merged 4 commits into
mainfrom
users/glhays/minorfoundation-repository-fkTest

Conversation

@glhays

@glhays glhays commented Jun 13, 2025

Copy link
Copy Markdown
Collaborator

@glhays glhays changed the title ShouldThrowDependencyValidationExceptionOnAddIfForeignKeyExceptionOccursAndLogItAsync -> FAIL MINOR FOUNDATION: Repository ForeignKey Tests Jun 13, 2025
@glhays glhays marked this pull request as draft June 13, 2025 01:11
@glhays glhays marked this pull request as ready for review June 13, 2025 23:45
@glhays glhays requested a review from Copilot June 13, 2025 23:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds handling for foreign key constraint conflicts in the repository service by introducing a new exception type and covering the new logic with unit tests.

  • Added a catch block for ForeignKeyConstraintConflictException in RepositoryService.Exceptions.cs
  • Introduced InvalidRepositoryReferenceException in the models
  • Added unit tests for Add and Modify flows to verify foreign key error handling

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
GitFyle.Core.Api/Services/Foundations/Repositories/RepositoryService.Exceptions.cs Added catch block to wrap FK constraint errors into validation exceptions
GitFyle.Core.Api/Models/Foundations/Repositories/Exceptions/InvalidRepositoryReferenceException.cs New exception class for invalid repository references
GitFyle.Core.Api.Tests.Unit/Services/Foundations/Repositories/RepositoryServiceTests.Exceptions.Modify.cs Test for Modify flow handling of foreign key conflicts
GitFyle.Core.Api.Tests.Unit/Services/Foundations/Repositories/RepositoryServiceTests.Exceptions.Add.cs Test for Add flow handling of foreign key conflicts
Comments suppressed due to low confidence (3)

GitFyle.Core.Api.Tests.Unit/Services/Foundations/Repositories/RepositoryServiceTests.Exceptions.Add.cs:202

  • To more accurately simulate a database foreign key violation, consider throwing ForeignKeyConstraintConflictException from storageBroker.InsertRepositoryAsync instead of dateTimeBroker.GetCurrentDateTimeOffsetAsync. This ensures the exception flows through the repository insert logic.
this.dateTimeBrokerMock.Setup(broker =>

GitFyle.Core.Api.Tests.Unit/Services/Foundations/Repositories/RepositoryServiceTests.Exceptions.Modify.cs:216

  • To better reflect where a foreign key error would occur, throw ForeignKeyConstraintConflictException from storageBroker.UpdateRepositoryAsync rather than from dateTimeBroker.GetCurrentDateTimeOffsetAsync. This aligns the test with the actual failure point.
this.dateTimeBrokerMock.Setup(broker =>

GitFyle.Core.Api/Models/Foundations/Repositories/Exceptions/InvalidRepositoryReferenceException.cs:11

  • [nitpick] Add XML documentation comments for InvalidRepositoryReferenceException to explain when this exception is thrown and its intended use.
public class InvalidRepositoryReferenceException : Xeption

@glhays glhays requested review from aosunlana and cjdutoit June 13, 2025 23:48
@glhays glhays merged commit b2551aa into main Jun 14, 2025
2 checks passed
@glhays glhays deleted the users/glhays/minorfoundation-repository-fkTest branch June 14, 2025 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MINOR FOUNDATIONS: Add Repository => Source FK Test

3 participants